<?php
/**
 * Text element
 *
 */
class ArrowFormSlideBar extends ArrowFormField{

	
	public function init(){
		parent::init();
		$jsData = array( "name" => $this->getProperty("name") , "min" => $this->getProperty("min"), "max" => $this->getProperty("max"), "info" => $this->getProperty( "info" ) );
		$this->registerJs( get_class($this), dirname(__FILE__)."/ArrowFormSlideBar.js", ".".self::CTRL_NAMESPACE."-form-slidebar", $jsData);
	}
	
	public function configure(){
		parent::configure();	
		$this->addProperties(array(
			"min" => 0,
			"max" => 100,
			"check" => 0,
			"value" => 0,
			"info" => true
		));
	}	
	
	
	public function validate( $proposedValue ){
		if(!is_numeric($proposedValue))
			return false;
		return true;
	}
	
	public function generateOutput(){
		$attribuites = array();
		$attribuites["name"] = $this->getHtmlName();
		$attribuites["value"] = $this->getValue();

		$info = $this->getProperty( "info" ) ;
		$short_name = $this->getProperty("name") ;
		
		$ret = "<div class='ctrl-form-slidebar' >" ;
		if( $info ) {
			$val = (int) $attribuites["value"] ;
			$ret .= "<span style=\"padding-left:5px;\" class='ctrl-slidebar-val-$short_name' >$val%</span>" ;	
		}
		$ret .= "<div style=\"float:right;width:90%;\" class=\"ctrl-slidebar-$short_name\" ></div><input id=\"ctrl-slidebar-$short_name\" type=\"hidden\" ".$this->genTagsFromArray($attribuites)." ".$this->addExternal()."/>";
	
		$ret .= "</div>";
		
		return $ret ;
	}


}
?>